home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / Source / Chapter 13 / Game / PlayerManager.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-01  |  1.7 KB  |  46 lines

  1. //-----------------------------------------------------------------------------
  2. // Manages the player's in the game. More specifically it manages The local
  3. // player and its input.
  4. //
  5. // Programming a Multiplayer First Person Shooter in DirectX
  6. // Copyright (c) 2004 Vaughan Young
  7. //-----------------------------------------------------------------------------
  8. #ifndef PLAYER_MANAGER_H
  9. #define PLAYER_MANAGER_H
  10.  
  11. //-----------------------------------------------------------------------------
  12. // Player Manager Class
  13. //-----------------------------------------------------------------------------
  14. class PlayerManager
  15. {
  16. public:
  17.     PlayerManager();
  18.     virtual ~PlayerManager();
  19.  
  20.     void Update( float elapsed );
  21.  
  22.     void SpawnLocalPlayer( long spawnPoint = -1 );
  23.     void SpawnPlayer( DPNID dpnid, D3DXVECTOR3 translation );
  24.  
  25.     PlayerObject *AddPlayer( PlayerInfo *player );
  26.     void RemovePlayer( DPNID dpnid );
  27.  
  28.     PlayerObject *GetLocalPlayer();
  29.     PlayerObject *GetPlayer( DPNID dpnid );
  30.     PlayerObject *GetNextPlayer( bool restart = false );
  31.     PlayerObject *GetViewingPlayer();
  32.  
  33. private:
  34.     LinkedList< PlayerObject > *m_players; // Linked list of player objects.
  35.     PlayerObject *m_viewingPlayer; // Pointer to the currently viewing player.
  36.  
  37.     bool m_localMovement; // Indicates if the local player moved in the current frame.
  38.     float m_localDrive; // Local player's drive direction.
  39.     float m_localStrafe; // Local player's strafe direction.
  40.     bool m_localFire; // Indicates if the local player is firing their weapon.
  41.  
  42.     bool m_spawnLocalPlayer; // Indicates if the local player needs to be spawned.
  43.     bool m_requestedSpawnPoint; // Indicates if the a spawn point has been requested.
  44. };
  45.  
  46. #endif